From 4edec9f99158b0ab2d89d39f9ea0cea2f811c445 Mon Sep 17 00:00:00 2001 From: "ach61@labyrinth.cl.cam.ac.uk" Date: Thu, 30 Oct 2003 18:03:05 +0000 Subject: [PATCH] bitkeeper revision 1.544 (3fa15259IWpuWetGe_175Hq5izSLnA) hypercall jumps to pervasive debugger --- .rootkeys | 1 + BitKeeper/etc/ignore | 1 + xen/common/debug.c | 84 +++++++++++++++++++++++++++ xen/common/dom0_ops.c | 3 +- xen/include/hypervisor-ifs/dom0_ops.h | 7 +-- xen/include/xeno/sched.h | 2 +- 6 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 xen/common/debug.c diff --git a/.rootkeys b/.rootkeys index 0c283bf879..4e753c27ca 100644 --- a/.rootkeys +++ b/.rootkeys @@ -234,6 +234,7 @@ 3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c 3ddb79bddEYJbcURvqqcx99Yl2iAhQ xen/common/block.c 3ddb79bdrqnW93GR9gZk1OJe1qK-iQ xen/common/brlock.c +3fa152581E5KhrAtqZef2Sr5NKTz4w xen/common/debug.c 3ddb79bdLX_P6iB7ILiblRLWvebapg xen/common/dom0_ops.c 3e6377e4i0c9GtKN65e99OtRbw3AZw xen/common/dom_mem_ops.c 3ddb79bdYO5D8Av12NHqPeSviav7cg xen/common/domain.c diff --git a/BitKeeper/etc/ignore b/BitKeeper/etc/ignore index 33a9945db7..25b9a3bed3 100644 --- a/BitKeeper/etc/ignore +++ b/BitKeeper/etc/ignore @@ -479,3 +479,4 @@ tools/misc/xen_cpuperf tools/misc/xen_log tools/misc/xen_refresh_dev xenolinux-2.4.22-sparse/arch/xeno/drivers/block/device +xen/common/debug.c~ diff --git a/xen/common/debug.c b/xen/common/debug.c new file mode 100644 index 0000000000..c20c5b21b5 --- /dev/null +++ b/xen/common/debug.c @@ -0,0 +1,84 @@ +/* + * debug.c + * + * xen pervasive debugger + */ + +#include +#include +#include +#include +#include +#include + +#define DEBUG_TRACE +#ifdef DEBUG_TRACE +#define TRC(_x) _x +#else +#define TRC(_x) +#endif + +void pdb_do_debug (dom0_op_t *op) +{ + op->u.debug.status = 0; + op->u.debug.out1 = op->u.debug.in2 + 10; + op->u.debug.out2 = op->u.debug.in1 + 100; + + TRC(printk("PDB: op:%c, dom:%x, in1:%x, in2:%x\n", + op->u.debug.opcode, op->u.debug.domain, + op->u.debug.in1, op->u.debug.in2)); + + if (op->u.debug.domain == 0) + { + op->u.debug.status = 1; + return; + } + + switch (op->u.debug.opcode) + { + case 'r' : + { + struct task_struct * p = find_domain_by_id(op->u.debug.domain); + if ( p != NULL ) + { + if ( (p->flags & PF_CONSTRUCTED) != 0 ) + { + wake_up(p); + reschedule(p); + } + put_task_struct(p); + } + else + { + op->u.debug.status = 2; /* invalid domain */ + } + break; + } + case 's' : + { + unsigned long cpu_mask; + struct task_struct * p = find_domain_by_id(op->u.debug.domain); + + if (p != NULL) + { + if (p->state != TASK_SUSPENDED) + { + cpu_mask = mark_hyp_event(p, _HYP_EVENT_STOP); + hyp_event_notify(cpu_mask); + } + put_task_struct(p); + } + else + { + op->u.debug.status = 2; /* invalid domain */ + } + break; + } + default : + { + printk("PDB error: unknown debug opcode %c (0x%x)\n", + op->u.debug.opcode, op->u.debug.opcode); + } + } + return; +} diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index d5d5e278f1..1356583bdd 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -310,8 +310,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op) case DOM0_DEBUG: { - op.u.debug.out1 = op.u.debug.in2 + 1; - op.u.debug.out2 = op.u.debug.in1 + 1; + pdb_do_debug(&op); copy_to_user(u_dom0_op, &op, sizeof(op)); ret = 0; } diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 55544e1626..c5c4f97298 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -106,16 +106,15 @@ typedef struct dom0_msr_st unsigned int in1, in2; /* OUT variables. */ unsigned int out1, out2; - } dom0_msr_t; typedef struct dom0_debug_st { /* IN variables. */ - int in1, in2; + char opcode; + int domain, in1, in2; /* OUT variables. */ - int out1, out2; - + int status, out1, out2; } dom0_debug_t; /* diff --git a/xen/include/xeno/sched.h b/xen/include/xeno/sched.h index bd517f9e97..b150072406 100644 --- a/xen/include/xeno/sched.h +++ b/xen/include/xeno/sched.h @@ -171,7 +171,7 @@ struct task_struct * TASK_UNINTERRUPTIBLE: Domain is blocked but may not be woken up by an * arbitrary event or timer. * TASK_WAIT: Domains CPU allocation expired. - * TASK_SUSPENDED: Domain is in supsended state (eg. start of day) + * TASK_SUSPENDED: Domain is suspended (startofday or pervasive debugger) * TASK_DYING: Domain is about to cross over to the land of the dead. * * If you update these then please update the mapping to text names in -- 2.30.2